<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 登录</title>
    <meta name="keywords" content="论坛，仗剑论坛，仗剑">
    <meta name="description" content="前台用户登录">
    <link rel="shortcut icon" href="img/favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <!--<script>if(window.top !== window.self){ window.top.location = window.location;}</script>-->
</head>

<body class="gray-bg" style="background:url('/img/login1.jpg')  no-repeat center fixed">

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <a href="index.jsp">

            <h1 class="logo-name">Z</h1>

        </a>
        <h3>欢迎加入 仗剑论坛</h3>

        <form class="m-t">
            <div class="form-group">
                <input type="text" id="username" class="form-control" placeholder="用户邮箱" autofocus>
            </div>
            <div class="form-group">
                <input type="password" id="password" class="form-control" placeholder="密码">
            </div>
            <!--button标签默认是submit行为，他会自动提交表单，但是我的表单没有action所以会刷新，我曹-->
            <button type="button" id='submit' onClick="submitf();" class="btn btn-primary block full-width m-b">登 录
            </button>

            <p class="text-muted text-center"><a href="login.html#">
                <small>忘记密码了？</small>
            </a> | <a href="register.html">注册一个新账号</a>
            </p>
            <p id="tip"></p>
        </form>
    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<!--layer插件-->
<script src="/js/plugins/layer/layer.min.js"></script>
<script type="text/javascript">
    function submitf() {
        $.ajax({
            type: 'post',
            url: "/checkLogin",
            cache: false,
            dataType: "text",
            data: {username: $('#username').val(), password: $('#password').val()},
            success: function (data) {
                if (data == "err") {
                    layer.tips("账号或密码错误", $('form'), {tips: [1, '#0FA6D8']}); //还可配置颜色
                } else if (data == 'success') {
                    var index = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    $('#submit').isDisabled;
                    setTimeout(function () {
                        top.location.href = '/login';
                    }, 2000);

                } else if (data == '-1') {
                    layer.tips("您的账号已永久被封", $('form'), {tips: [2, '#0FA6D8']});
                } else {
                    layer.tips("您的账号还有" + data + "天解封", $('form'), {tips: [2, '#0FA6D8']});
                }
            }

        });
    }


</script>


</body>

</html>
